/*
 * @Date: 2023-03-06 13:42:55
 * @LastEditTime: 2023-03-22 12:27:21
 * @FilePath: /NLK/src/router/index.ts
 * 介绍:路由文件
 */

import {
  createRouter,
  // createWebHistory,
  createWebHashHistory,
  RouteRecordRaw,
} from "vue-router"; //引入路由
import { importRouterModules } from "./importGlob";

const routes: Array<RouteRecordRaw> = [];

routes.push(...importRouterModules());
const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

//解析守卫
// router.beforeResolve(async (to) => {
//   return true;
// });

//前置路由守卫
router.beforeEach(async (to, from, next) => {
  const whiteList = ["/"];
  if (whiteList.includes(to.path as string)) return next();
  next();
});

export default router;
